package util

import "github.com/gin-gonic/gin"

type res struct {
	Success bool        `json:"success"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"message,omitempty"`
}

func ResOK(c *gin.Context, data interface{}) {
	c.JSON(200, res{true, data, ""})
}

func ResErr(c *gin.Context, message string) {
	if message == "" {
		message = "未知错误"
	}
	c.JSON(200, res{false, nil, message})
}

func ResParamErr(c *gin.Context, message string) {
	ResErr(c, "请求参数错误："+message)
}

func ResSysErr(c *gin.Context, message string) {
	ResErr(c, "系统错误："+message)
}
